class ChildPanle extends egret.DisplayObjectContainer {
	protected context: any;
	private speed = 0.2;
	public constructor(context: any) {
		super();
		this.context = context;
		this.alpha = 0;
	}

	protected onAddToStage() {
		this.openAm();
	}

	public openAm(): void {
		this.removeEventListener(egret.Event.ENTER_FRAME, this.enterFrameHandler, this);
		this.addEventListener(egret.Event.ENTER_FRAME, this.enterFrameHandler, this);
	}
	public closeAm(): void {
		this.removeEventListener(egret.Event.ENTER_FRAME, this.closeFrameHandler, this);
		this.addEventListener(egret.Event.ENTER_FRAME, this.closeFrameHandler, this);
	}
	/**打开时逐帧运动*/
	private enterFrameHandler(event: egret.Event): void {
		if (this.alpha < 1) {
			this.alpha += this.speed;
		} else {
			this.pauseOpenAm();
		}
	}

    /**
     * 关闭时动画运动
     * @param event
     */
	private closeFrameHandler(event: egret.Event): void {
		if (this.alpha > 0) {
			this.alpha -= this.speed;
		} else {
			this.pauseOpenAm();
			if (this.parent) {
				this.parent.removeChild(this);
			}
		}
	}
	/**暂停打开时动画*/
	public pauseOpenAm(): void {
		this.removeEventListener(egret.Event.ENTER_FRAME, this.enterFrameHandler, this);
	}

	/**暂停关闭时的动画*/
	public pauseCloseAm(): void {
		this.removeEventListener(egret.Event.ENTER_FRAME, this.closeFrameHandler, this);
	}
}